a11y: Get lockbutton text directly
authorBenjamin Otte <otte@redhat.com>
Mon, 9 Jul 2012 00:58:22 +0000 (02:58 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Jul 2012 00:58:22 +0000 (02:58 +0200)
Instead of letting the generic button code attempt to find the currently
displayed text, just return the text directly.

https://bugzilla.gnome.org/show_bug.cgi?id=677347

gtk/Makefile.am
gtk/a11y/gtklockbuttonaccessible.c
gtk/gtklockbutton.c
gtk/gtklockbuttonprivate.h [new file with mode: 0644]

index 61866e81f86b35d6cb7d894b9c8da394a032fff4..d3e785c2865c5f9a8b53acc5332010bd71f24619 100644 (file)
@@ -481,6 +481,7 @@ gtk_private_h_sources =             \
        gtkimcontextsimpleseqs.h \
        gtkintl.h               \
        gtkkeyhash.h            \
+       gtklockbuttonprivate.h  \
        gtkmenubuttonprivate.h  \
        gtkmenuprivate.h        \
        gtkmenuitemprivate.h    \
index ee1cccd434b3750f9ffda1d18e72baaa55b4f96f..a24e3109b13b00022d90540f9f97c5dea696700c 100644 (file)
 
 #include "config.h"
 
-#include <string.h>
-#include <gtk/gtk.h>
+#include "gtk/gtklockbuttonprivate.h"
 #include "gtklockbuttonaccessible.h"
 
 G_DEFINE_TYPE (GtkLockButtonAccessible, _gtk_lock_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE)
 
+static const gchar *
+gtk_lock_button_accessible_get_name (AtkObject *obj)
+{
+  GtkLockButton *lockbutton;
+
+  lockbutton = GTK_LOCK_BUTTON (gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)));
+  if (lockbutton == NULL)
+    return NULL;
+
+  return _gtk_lock_button_get_current_text (lockbutton);
+}
+
 static void
 _gtk_lock_button_accessible_class_init (GtkLockButtonAccessibleClass *klass)
 {
+  AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
+
+  atk_object_class->get_name = gtk_lock_button_accessible_get_name;
 }
 
 static void
index 6fc45367b8127d4b20235c37142f56ae9a9d6e35..9cb828b843f8f48aebffb10fba50128eaade0c73 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "config.h"
 
-#include "gtklockbutton.h"
+#include "gtklockbuttonprivate.h"
 #include "gtkbox.h"
 #include "gtkimage.h"
 #include "gtklabel.h"
@@ -564,3 +564,19 @@ gtk_lock_button_set_permission (GtkLockButton *button,
       g_object_notify (G_OBJECT (button), "permission");
     }
 }
+
+const char *
+_gtk_lock_button_get_current_text (GtkLockButton *button)
+{
+  GtkLockButtonPrivate *priv;
+
+  g_return_val_if_fail (GTK_IS_LOCK_BUTTON (button), NULL);
+
+  priv = button->priv;
+
+  if (gtk_widget_get_visible (priv->label_lock))
+    return gtk_label_get_text (GTK_LABEL (priv->label_lock));
+  else
+    return gtk_label_get_text (GTK_LABEL (priv->label_unlock));
+}
+
diff --git a/gtk/gtklockbuttonprivate.h b/gtk/gtklockbuttonprivate.h
new file mode 100644 (file)
index 0000000..f029bf8
--- /dev/null
@@ -0,0 +1,30 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2010 Red Hat, Inc.
+ * Author: Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_LOCK_BUTTON_PRIVATE_H__
+#define __GTK_LOCK_BUTTON_PRIVATE_H__
+
+#include "gtklockbutton.h"
+
+G_BEGIN_DECLS
+
+const char *    _gtk_lock_button_get_current_text       (GtkLockButton  *button);
+
+G_END_DECLS
+
+#endif /* __GTK_LOCK_BUTTON_PRIVATE_H__ */